package myapp.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

public class DataProvider {
	protected static DatabaseHelper myDatabaseHelper;


	protected SQLiteDatabase db;
	protected final Context context;

	public DataProvider(Context _context) {
		context = _context;
		myDatabaseHelper = new DatabaseHelper(context, DatabaseHelper.dbName, null, DatabaseHelper.DATABASE_VERSION);
	}

	/** Close the database */
	public void close() {
		db.close();
	}
	
	/** Open the database */
	public void open() throws SQLiteException {  
		try {
			db = myDatabaseHelper.getWritableDatabase();
		}
		catch (SQLiteException ex) {
			db = myDatabaseHelper.getReadableDatabase();
		}	  
	}
}
